import React, { Component } from "react";
// import Axios from "axios";
import { Pagination } from "antd";
class View extends Component {
  constructor() {
    super();
    this.state = {
      list: [],
      current: 1,
    };
    this.time = null;
  }
  onChange = (page) => {
    // console.log(this.state.list);
    this.setState({
      current: page,
    });
    this.time = setTimeout(() => {
      this.change(page);
    }, 0);
  };
  change = (current) => {
    // Axios.get("/home/mediareports", {
    //   params: {
    //     page_number: current,
    //     page_size: 10,
    //   },
    // }).then((result) => {
    //   this.setState({
    //     list: result.data.data,
    //   });
    // });
  };
  componentDidMount() {
    clearTimeout(this.time);
    this.change(this.state.current);
  }
  // componentDidUpdate() {
  //   Axios.get("/home/mediareports", {
  //     params: {
  //       page_number: this.state.current,
  //       page_size: 20,
  //     },
  //   }).then((result) => {
  //     this.setState({
  //       list: result.data.data,
  //     });
  //   });
  // }
  render() {
    return (
      <div>
        <ul>
          {this.state.list.map((item, index) => {
            return <li key={index}>{item.main_title}</li>;
          })}
        </ul>
        <Pagination
          current={this.state.current}
          onChange={this.onChange}
          total={50}
        />
      </div>
    );
  }
}
export default View;
